package com.sit.estatemanagementserver.service;

import com.sit.estatemanagementserver.dao.OwnerDao;
import com.sit.estatemanagementserver.enity.Owner;
import com.sit.estatemanagementserver.enity.Register;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Autowired
    private OwnerDao ownerDao;

    // 注册
    public boolean register(Register register) {
        // 无需修改
        if (ownerDao.getOwner(register.getPhone()) != null) {
            return false;
        }
        return ownerDao.register(register);
    }

    // 登录
    public boolean login(String phone, String password) {
        // 无需修改
        Owner owner = ownerDao.getOwner(phone);
        return owner != null && owner.getPassword().equals(password);
    }

    public Owner getOwnerByPhone(String phone) {
        // 无需修改
        return ownerDao.getOwner(phone);
    }
}